/**
 * created by 小卷毛, 2020/9/13
 * Copyright (c) 2020, 416143467@qq.com All Rights Reserved.
 * #                   *********                            #
 * #                  ************                          #
 * #                  *************                         #
 * #                 **  ***********                        #
 * #                ***  ****** *****                       #
 * #                *** *******   ****                      #
 * #               ***  ********** ****                     #
 * #              ****  *********** ****                    #
 * #            *****   ***********  *****                  #
 * #           ******   *** ********   *****                #
 * #           *****   ***   ********   ******              #
 * #          ******   ***  ***********   ******            #
 * #         ******   **** **************  ******           #
 * #        *******  ********************* *******          #
 * #        *******  ******************************         #
 * #       *******  ****** ***************** *******        #
 * #       *******  ****** ****** *********   ******        #
 * #       *******    **  ******   ******     ******        #
 * #       *******        ******    *****     *****         #
 * #        ******        *****     *****     ****          #
 * #         *****        ****      *****     ***           #
 * #          *****       ***        ***      *             #
 * #            **       ****        ****                   #
 */
package com.sgcc.pda.lib_tools_database.bean.ticket;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Keep;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.annotation.Unique;
import org.greenrobot.greendao.annotation.Generated;

import java.util.List;

import org.greenrobot.greendao.DaoException;

import com.sgcc.pda.lib_tools_database.gen.DaoSession;
import com.sgcc.pda.lib_tools_database.gen.LocalImageDao;
import com.sgcc.pda.lib_tools_database.gen.TicketMeetingDao;

/**
 * 描 述：离线班前会提交数据
 * 作 者：小卷毛  2020-12-15 17:05
 * 修改描述：
 * 修 改 人：
 * 修改版本：
 */
@Entity
public class TicketMeeting {

    @Id
    @Unique
    private String WT_ID; //工作票ID
    private String START_TIME; //开始时间
    private String END_TIME; //结束时间
    private String WT_OPT_USER; //操作人
    private String WT_CREATE_DATE; //入库时间
    private String WT_ORG_NO; //供电单位

    private String ITEMS_STRING;

    @ToMany(referencedJoinProperty = "parentId")
    private List<LocalImage> FILE_LIST;

    @ToMany(referencedJoinProperty = "parentId")
    private List<LocalImage> SIGNS;

    @Transient
    private List<TicketDetail.QstItem> ITEMS;
    /**
     * Used to resolve relations
     */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /**
     * Used for active entity operations.
     */
    @Generated(hash = 2003952956)
    private transient TicketMeetingDao myDao;

    @Generated(hash = 591341074)
    public TicketMeeting(String WT_ID, String START_TIME, String END_TIME,
                         String WT_OPT_USER, String WT_CREATE_DATE, String WT_ORG_NO,
                         String ITEMS_STRING) {
        this.WT_ID = WT_ID;
        this.START_TIME = START_TIME;
        this.END_TIME = END_TIME;
        this.WT_OPT_USER = WT_OPT_USER;
        this.WT_CREATE_DATE = WT_CREATE_DATE;
        this.WT_ORG_NO = WT_ORG_NO;
        this.ITEMS_STRING = ITEMS_STRING;
    }

    @Generated(hash = 347977709)
    public TicketMeeting() {
    }

    public String getWT_ID() {
        return this.WT_ID;
    }

    public void setWT_ID(String WT_ID) {
        this.WT_ID = WT_ID;
    }

    public String getSTART_TIME() {
        return this.START_TIME;
    }

    public void setSTART_TIME(String START_TIME) {
        this.START_TIME = START_TIME;
    }

    public String getEND_TIME() {
        return this.END_TIME;
    }

    public void setEND_TIME(String END_TIME) {
        this.END_TIME = END_TIME;
    }

    public String getWT_OPT_USER() {
        return this.WT_OPT_USER;
    }

    public void setWT_OPT_USER(String WT_OPT_USER) {
        this.WT_OPT_USER = WT_OPT_USER;
    }

    public String getWT_CREATE_DATE() {
        return this.WT_CREATE_DATE;
    }

    public void setWT_CREATE_DATE(String WT_CREATE_DATE) {
        this.WT_CREATE_DATE = WT_CREATE_DATE;
    }

    public String getWT_ORG_NO() {
        return this.WT_ORG_NO;
    }

    public void setWT_ORG_NO(String WT_ORG_NO) {
        this.WT_ORG_NO = WT_ORG_NO;
    }

    public String getITEMS_STRING() {
        return this.ITEMS_STRING;
    }

    public void setITEMS_STRING(String ITEMS_STRING) {
        this.ITEMS_STRING = ITEMS_STRING;
    }

    public void setFILE_LIST(List<LocalImage> FILE_LIST) {
        this.FILE_LIST = FILE_LIST;
    }

    public void setSIGNS(List<LocalImage> SIGNS) {
        this.SIGNS = SIGNS;
    }

    public List<TicketDetail.QstItem> getITEMS() {
        return ITEMS;
    }

    public void setITEMS(List<TicketDetail.QstItem> ITEMS) {
        this.ITEMS = ITEMS;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Keep
    public List<LocalImage> getFILE_LIST() {
        if (FILE_LIST == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            LocalImageDao targetDao = daoSession.getLocalImageDao();

            List<LocalImage> FILE_LISTNew = targetDao.queryBuilder()
                    .where(
                            LocalImageDao.Properties.ParentId.eq(WT_ID),
                            LocalImageDao.Properties.AttachMode.eq("2"),
                            LocalImageDao.Properties.AttachName.eq("")
                    ).list();
            synchronized (this) {
                if (FILE_LIST == null) {
                    FILE_LIST = FILE_LISTNew;
                }
            }
        }
        return FILE_LIST;
    }

    /**
     * Resets a to-many relationship, making the next get call to query for a fresh result.
     */
    @Generated(hash = 731707205)
    public synchronized void resetFILE_LIST() {
        FILE_LIST = null;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Keep
    public List<LocalImage> getSIGNS() {
        if (SIGNS == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            LocalImageDao targetDao = daoSession.getLocalImageDao();

            List<LocalImage> SIGNSNew = targetDao.queryBuilder()
                    .where(
                            LocalImageDao.Properties.ParentId.eq(WT_ID),
                            LocalImageDao.Properties.AttachMode.eq("2"),
                            LocalImageDao.Properties.AttachName.eq("operatorId")
                    ).list();
            synchronized (this) {
                if (SIGNS == null) {
                    SIGNS = SIGNSNew;
                }
            }
        }
        return SIGNS;
    }

    /**
     * Resets a to-many relationship, making the next get call to query for a fresh result.
     */
    @Generated(hash = 855845146)
    public synchronized void resetSIGNS() {
        SIGNS = null;
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /**
     * called by internal mechanisms, do not call yourself.
     */
    @Generated(hash = 1004754905)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getTicketMeetingDao() : null;
    }

}
